package cz.boxdesign.library.entity.dao.query;

import cz.boxdesign.core.dao.query.Query;

public enum UserSqlQuery implements Query {
  UNKNOWN("", 0),

  INSERT(
      "insert into uzivatel(id,jm_u, prijmeni_u,login_u,pass_u,is_admin,ulice_u,mesto_u,psc_u,datum_registrace,obdobi_od,obdobi_do,plat,rodne_cislo,zamestnan_od,zamestnan_do) values (uzivatel_sequence.nextval,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
      Query.INSERT),
  UPDATE(
      "update uzivatel set pass_u = ?,ulice_u = ?,mesto_u = ?,psc_u = ?, plat = ? where id = ? and login_u = ?",
      Query.UPDATE),
  DELETE("delete from uzivatel where id = ? and login_u = ?", Query.DELETE),
  SELECT("select * from uzivatel where 1=1 ", Query.SELECT);

  private String query;
  private Integer value;

  private UserSqlQuery(String query, Integer value) {
    this.query = query;
    this.value = value;
  }

  /* (non-Javadoc)
   * @see cz.boxdesign.library.common.dao.Queries#getQuery()
   */
  @Override
  public String getQuery() {
    return query;
  }

  /* (non-Javadoc)
   * @see cz.boxdesign.library.common.dao.Queries#getValue()
   */
  @Override
  public Integer getValue() {
    return value;
  }

  /**
   * @param value
   *          the status value
   * @return return status object by value or {@link #UNKNOWN} if not found
   */
  public static UserSqlQuery getByValue(Integer value) {
    for (UserSqlQuery mps : values()) {
      if (mps.getValue().equals(value)) {
        return mps;
      }
    }
    return UNKNOWN;
  }
}
